package com.jiazhong.project.servlet;

import com.jiazhong.project.pojo.Brand;
import com.jiazhong.project.service.BrandService;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/brandServlet")
public class BrandServlet extends HttpServlet {
    BrandService brandService=new BrandService();
    @Override

    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //调用service的方法
        final List<Brand> brands = brandService.selectAll();
        req.setAttribute("brands",brands);
        final RequestDispatcher requestDispatcher = req.getRequestDispatcher("/brand.jsp");
        requestDispatcher.forward(req,resp);
    }
}


